<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no">
    <script src="vue.min.js"></script>
    <script src="https://cdn.bootcss.com/vue-router/3.1.2/vue-router.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .v-enter, .v-leave-to {
            opacity: 0;
            transform: translateY(20px);
        }

        .v-enter-active, .v-leave-active {
            transition: all 0.5s ease;
        }

    </style>
</head>
<body>

<div id="app">
    <router-link to="/">account</router-link>

    <router-view></router-view>
</div>

<template id="temple">
    <div>
        <h1>这是account组件</h1>
        <router-link to="/account/login" >登录</router-link>
        <router-link to="/account/zhuce" >注册</router-link>

        <transition mode="out-in">
            <router-view></router-view>
        </transition>
    </div>
</template>


<script>
    var account = {
        template: '#temple',
    };

    //组件模板对象
    var login = {
        template: '<h3>我是登录组件</h3>',
    };
    var zhuce = {
        template: '<h3>我是注册组件</h3>',
    };

    var router = new VueRouter({
        routes: [
            {
                path: '/',
                redirect: '/account'
            },
            {
                path: '/account',
                component: account,
                children: [
                    {path: 'login', component: login},
                    {path: 'zhuce', component: zhuce},
                ]
            },
        ]
    });

    let app = new Vue({
        el: '#app',
        data() {
            return {}
        },
        methods: {},
        components: {
            account
        },
        router,
    })
</script>
</body>
</html>